home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include "resources.h"
-
- struct AppData {
- public:
- char* redName;
- char* greenName;
- char* blueName;
- char* purpleName;
- char* laserName;
- char* missileName;
-
- // ship class names
- char* regularName;
-
- // data file directories
- char* explosionDir;
- char* soundDir;
- char* helpFile;
- };
-
- static int resourcesLoaded = FALSE;
- static AppData swData;
- static XtResource swResources[] = {
- { "redName", "RedName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, redName),
- XmRString, "Red" },
- { "greenName", "GreenName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, greenName),
- XmRString, "Green" },
- { "blueName", "BlueName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, blueName),
- XmRString, "Blue" },
- { "purpleName", "PurpleName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, purpleName),
- XmRString, "Purple" },
- { "laserName", "LaserName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, laserName),
- XmRString, "Laser" },
- { "missileName", "MissileName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, missileName),
- XmRString, "Missile" },
- { "explosionDirectory", "ExplosionDirectory",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, explosionDir),
- /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
- /*
- uncomment the following and comment the
- active line below if you want to access
- the help file from the default location
- under "/usr/src/IndigoGames..."
- XmRString, "." },
- */
- XmRString, "../data/sw/" },
- { "soundDirectory", "SoundDirectory",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, soundDir),
- /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
- /*
- uncomment the following and comment the
- active line below if you want to access
- the help file from the default location
- under "/usr/src/IndigoGames..."
- XmRString, "." },
- */
- XmRString, "../data/sw/" },
- { "helpFile", "HelpFile",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, helpFile),
- /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
- /*
- uncomment the following and comment the
- active line below if you want to access
- the help file from the default location
- under "/usr/src/IndigoGames..."
- XmRString, "/usr/src/IndigoGames/IndiZone/sw/sw.hlp" },
- */
- XmRString, "../data/sw/swHelp.showcase" },
-
- { "regularName", "RegularName",
- XmRString, sizeof(char*),
- XtOffsetOf(AppData, regularName),
- XmRString, "Regular" }
- };
- static char* fallbacks[] = {
- "*label*fontList: -*-helvetica-bold-r-normal-*-14-*",
- "*info*fontList: -*-helvetica-medium-r-normal-*-14-*",
- "*XmPushButton*fontList: -*-helvetica-medium-r-normal-*-14-*",
- "*XmPushButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14-*",
- "*XmToggleButton*fontList: -*-helvetica-medium-r-normal-*-14-",
- "*XmToggleButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14-*",
- "*XmPushButton*marginHeight: 4",
- "*XmPushButton*marginWidth: 7",
- "*XmToggleButtonGadget*spacing: 4",
- "*XmToggleButton*spacing: 4",
- "*XmText*marginHeight: 4",
- "*foreground: Black",
- "*background: #c1c1c1",
- "*highlightThickness: 0",
- "*fillOnSelect: True",
- "*visibleWhenOff: True",
- "*selectColor: #ffff00",
- "*XmText.background: #999999",
- "*status*fractionBase: 10",
- "*status*rightPosition: 3",
- "*weapons*label.labelString: Weapons:",
- "*shields*label.labelString: Shields:",
- "*laser*label.labelString: Laser:",
- "*missile*label.labelString: Missiles:",
- "*thrust*label.labelString: Thrust:",
- "*fuel*label.labelString: Fuel:",
- "*radio*label.labelString: Radio:",
- "*radio*off.labelString: Off",
- "*radio*team.labelString: Team",
- "*radio*all.labelString: All",
- "*sound*label.labelString: Sound:",
- "*sound*off.labelString: Off",
- "*sound*warning.labelString: Warn",
- "*sound*all.labelString: All",
- "*radar*label.labelString: Radar:",
- "*target*label.labelString: Target:",
- "*message*label.labelString: Messages:",
- "*score*label.labelString: Score:",
- "*players*label.labelString: Players:",
- "*flag*label.labelString: Flag:",
- "*pause.labelString: Pause",
- "*help.labelString: Help",
- "*quit.labelString: Quit",
- NULL };
-
- void setFallbacks(XtAppContext context)
- {
- XtAppSetFallbackResources(context, fallbacks);
- }
-
- void loadResources(Widget top)
- {
- if (resourcesLoaded) return;
- XtVaGetApplicationResources(top, (XtPointer)&swData,
- swResources, XtNumber(swResources), NULL);
- }
-
- char* weaponName(Weapon w)
- {
- switch (w) {
- case Laser: return swData.laserName;
- case Missile: return swData.missileName;
- }
- return NULL;
- }
-
- char* teamName(Team t)
- {
- switch (t) {
- case NoTeam: return "nil";
- case RedTeam: return swData.redName;
- case GreenTeam: return swData.greenName;
- case BlueTeam: return swData.blueName;
- case PurpleTeam: return swData.purpleName;
- }
- return NULL;
- }
-
- long teamColor(Team t)
- {
- switch (t) {
- case NoTeam: return 0xff000000;
- case RedTeam: return 0xff0000ff;
- case GreenTeam: return 0xff00ff00;
- case BlueTeam: return 0xffff0000;
- case PurpleTeam: return 0xffff00ff;
- }
- return 0xff000000;
- }
-
- float* teamColor(Team t, float i)
- {
- static float c[3];
-
- switch (t) {
- case RedTeam:
- c[0] = i; c[1] = c[2] = 0.0;
- break;
- case GreenTeam:
- c[1] = i; c[0] = c[2] = 0.0;
- break;
- case BlueTeam:
- c[2] = i; c[0] = c[1] = 0.0;
- break;
- case PurpleTeam:
- c[0] = c[2] = i; c[1] = 0.0;
- break;
- default:
- case NoTeam:
- c[0] = c[1] = c[2] = i;
- break;
- }
- return c;
- }
-
- char* shipClassName(ShipClass c)
- {
- switch (c) {
- case ShipClassRegular:
- return swData.regularName;
- }
- return "???";
- }
-
- char* explosionDirectory()
- {
- return swData.explosionDir;
- }
-
- char* soundsDirectory()
- {
- return swData.soundDir;
- }
-
- char* helpFile()
- {
- return swData.helpFile;
- }
-